package main

import (
	"fmt"
	"math/cmplx"
	"math"
)

//作用域  包变量
//var aa = 1
//var kk = "1"
//var bb = true
var (
	aa = 1
	kk = "1"
	bb = true
)

func variableZeroValue() {

	var a int
	var s string
	fmt.Printf("%d  %q \n",a,s)
	fmt.Println(a,s)
}
func variableInitialValue() {

	var a , b int = 3,4
	var s string = "abc"
	//fmt.Printf("%d  %q \n",a,s)
	fmt.Println(a,b,s)
}
func variableTypeDeduction() {

	var a , b,c,d,e  = 3,4,true,"yes",12
	//fmt.Printf("%d  %q \n",a,s)
	fmt.Println(a,b,c,d,e)
}
func variableShorter() {

	 a , b,c,d,e  := 3,4,true,"yes",12
	 b = 5
	//fmt.Printf("%d  %q \n",a,s)
	fmt.Println(a,b,c,d,e)
}
func main() {
	//variableZeroValue()
	//variableInitialValue()
	//variableTypeDeduction()
	//variableShorter()
	//fmt.Println("Hello World")
	//fmt.Println(aa,bb,kk)
	//


	//euler()
	//triangle()
	//consts()
	enums()
}

func euler()  {
	//c := 3 + 4i
	//fmt.Println(cmplx.Abs(c))  //out:5

	fmt.Printf("%.3f \n",cmplx.Exp(1i*math.Pi) +1)//
	fmt.Printf("%.3f \n",cmplx.Pow(math.E, 1i * math.Pi) +1)//
}

func triangle()  {
	var a,b = 3,4
	var c int
	c = int(math.Sqrt(float64(a*a +b*b)))
	fmt.Println(c)
}

func consts()  {
	//const fileName = "abc.txt"
	//const a , b   = 3,4
	//
	const (
		fileName = "abc.txt"
		 a , b   = 3,4
	)
	var c int
	c = int(math.Sqrt(a*a+b*b))
	fmt.Println(fileName,c)
}

func enums()  {
	//const(
	//	cpp = 0
	//	java= 1
	//	python = 2
	//	golang = 3
	//)

	//iota 代表自增
	const(
		cpp = iota
		//java
		_
		python
		golang
		JavaScript
	)

	const(
		b = 1 << (10* iota)
		kb
		mb
		gb
		tb
		pb
	)

	fmt.Println(cpp,JavaScript,python,golang)
	fmt.Println(b,kb,mb,gb,tb,pb)

}